
<extend name="Application/Admin/View/layout.html" />
<block name="mid">
     <div id="page-wrapper">
            <div id="page-inner">
                <div class="row">
                    <div class="col-md-12">
                        <h1 class="page-head-line">角色添加</h1>
                        <h1 class="page-subhead-line">This is dummy text , you can replace it with your original text. </h1>

                    </div>
                </div>
                <!-- /. ROW  -->
                <div class="row">

<div class="col-md-6 col-sm-6 col-xs-12">
               <div class="panel panel-danger">
                        <div class="panel-heading">
                           SINGUP FORM
                        </div>
                        <div class="panel-body">
                            <form role="form"  action="" method="post" enctype="multiple/form-data">


                                     <div class="form-group">
                                            <label>角色名称</label>
                                            <input type="text" class="form-control" name="title">
                                     <p class="help-block">Help text here.</p>
                                        </div>



                                         <div class="form-group">
                                            <label>是否显示</label>
                                            <div class="radio">
                                                <label>
                                                    <input type="radio" name="status" id="optionsRadios1" value="1" checked="">是
                                                </label>
                                            </div>
                                            <div class="radio">
                                                <label>
                                                    <input type="radio" name="status" id="optionsRadios2" value="2">否
                                                </label>
                                            </div>

                                        </div>
                                    <p class="help-block">Help text here.</p>
                                        <button class="btn btn-danger" type="submit">提交 Now </button>
       <foreach name="top_nav" item="v"  key="k">


                                        <div class="checkbox">

                                            <label>
                                                <input type="checkbox" value="<?php echo $v['id'];?>" name="rules[]" class="fuji"><?php echo $v['name'];?>
                                            </label>
<br>
                                           <foreach name="child_nav" item="ve"  key="k">
                                                <?php if($v['id']==$ve['pid']){?>

                                                    <label>
                                                        <input type="checkbox" value="<?php echo $ve['id'];?>" name="rules[]" class="ziji">
                                                             <?php echo $ve['name'];?>
                                                    </label>

                                                <?php } ?>


                                           </foreach>

                                        </div>
                                        <br>

                               </foreach>
                               <input type="checkbox" value="" class="qselect" name="rules[]" >
                                            <label>全选/反选</label>
                                    </form>
                            </div>
                        </div>
                            </div>
        </div>
             <!--/.ROW-->


            </div>
            <!-- /. PAGE INNER  -->
        </div>

        </block>
         <block name="js">
    <script  type="text/javascript" src="__ROOT____Admin__assets/js/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(function(){

    $(".qselect").click(function(){

        if($(this).is(':checked')){
            $("input[name='rules[]']").prop('checked', true)
        }else{
            $("input[name='rules[]']").prop('checked', false)
        }

    })
    $(".ziji").click(function(){

           // 获取所有选择框中已经选中状态的个数
            var len = $(this).parent().find(':checkbox:checked').length;


            // 个数大0
            if(len>0){
                    //$("input[name='rules[]']").prop('checked', true)
             // 把最上级的选择框选中
            $(this).parent().parent().find('.fuji').prop('checked',true);

            }else{
                // 把最上级的选择框取消选中
                 $(this).parent().parent().find('.fuji').prop('checked',false);

    }

    })


      $(".fuji").click(function(){

        if($(this).is(':checked')){
            $(this).parent().parent().find("input[name='rules[]']").prop('checked', true)
        }else{
            $(this).parent().parent().find("input[name='rules[]']").prop('checked', false)
        }

    })

    })

</script>
</block>